#ifndef SOURCE_H
#define SOURCE_H

#include <string>
#include <fstream>
#include <vector>
#include <cassert>
using namespace std;
#include "Signal.h"
// -----------------------------------------------------
class source_fromfile:public block{
  int    t_idx; // Points to the NEXT changing point
  int    t_node;
  vector<double> time;
  vector<double> signal;
  ifstream fin;
public:
  source_fromfile(const char* filename);
  ~source_fromfile();
  virtual void update(double time_sys);
  virtual void reset();
};
// -----------------------------------------------------
class source_constant:public block{
  double value;
public:
  source_constant(double iValue);
  ~source_constant();
  virtual void reset();
  virtual void update(double time_sys);
};
// -----------------------------------------------------
// u = A*sin(2*pi*f*t+theta)
class source_sin{
  int t_idx;
  int t_node;
  double n;
  double A;
  double theta;
public:
  source_sin(const double n);
  //~source_sin();
  double update(const double time_sys);
};
// -----------------------------------------------------
// A square wave with period = PERIOD
// u = K for n*tp<=t<(ratio+n)*tp for n = 0,1,2,...
// u = 0 for (ratio+n)*tp <=t< (n+1)*tp
class source_squarewave{
  double period;
  double ratio;
public:
  source_squarewave(const double iPeriod, const double iRatio);
  double update(const double time_sys);
};
// -----------------------------------------------------
// white noise with normal distribution, zero mean and variance SIGMA2
class source_whitenoise{
  double sigma2;
public:
  source_whitenoise(const double iSigma2);
};
// -----------------------------------------------------
// A sinusoid wave in $x\in[0,XYmax)$ with the form
//   z(x,y) = z_mean+A\sin(2k\pi x/XYmax)
// The output is the value of z(x) at L discrete positions.
class source_sin_spatial:public block{
  double XYmax;
  int L;
  double mean;
  double A;
  double k; 
public:
  source_sin_spatial(double iXYmax, int iL, double iMean, double iA, double ik);
  ~source_sin_spatial();
  virtual void update(double time_sys);
};
#endif
